import { saveReminder } from '@/api/order'
import { ref } from 'vue'
import { ReminderForm } from './types'

export default function (ids: Array<string>) {
  // 表单
  const form = ref<ReminderForm>({
    content: '',
    remindEmpType: [2],
    workIds: ids,
  })

  // 催单加载
  const saveReminderLoading = ref(false)

  // 催单方法
  const saveReminderFn = async () => {
    saveReminderLoading.value = true
    const res = await saveReminder(form.value)
    saveReminderLoading.value = false
    return res.data as { code: number; data: object; message: string; success: boolean }
  }

  return {
    form,
    saveReminderLoading,
    saveReminderFn,
  }
}
